package com.example.mobile2030606148tdhhomework0421;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class PartRVAdapter extends RecyclerView.Adapter<PartRVAdapter.ViewHolder> {
    String [] partName;
    String [] partName2;
    public PartRVAdapter(String[] partName2, String [] partName){
        this.partName=partName;
        this.partName2=partName;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(
                R.layout.item_rv_main_part,parent,false
        );
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.tvPart.setText(partName[position]);
        holder.tvPart1.setText(partName2[position]);

    }

    @Override
    public int getItemCount() {
        return partName.length;
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tvPart;
        TextView tvPart1;
        public ViewHolder(@NonNull View itemView){
            super(itemView);
            this.tvPart=itemView.findViewById(R.id.tv_item_part);
            this.tvPart1=itemView.findViewById(R.id.tv_item_part1);
        }
    }
}
